import LocalStorage from "../../engine/LocalStorage";
import { Logger } from "../../engine/Logger";
import { GameConfig } from "./GameConfig";
import { RoomConfig } from "./RoomConfig";

const Local_Key:string = "RoomConfig_huanghua_mj"

export class RoomConfig_huanghua_mj extends RoomConfig {

    public gameType: number = GameConfig.Game_Type.huanghua_mj
    public fangpao_type: number = 0; //
    public static fangpao_type = {
        dianpao_sanjiashu: 0, //点炮3家输
        dianpao_shu: 1, //谁点炮谁输
        dianpao_shu_all: 2, //点炮包赔
    }

    public static fangpao_type_name: Array<string> = [
        "点炮3家输", "谁点炮谁输", "点炮包赔"
    ]


    //人数配置
    public static renshuConfig: Array<number> = [
        4, 3, 2
    ]

    //局数配置
    public static jushuConfig: Array<number> = [
        4, 8, 12, 16
    ]

    //局数花费钻石配置
    public static fangfeiConfig: Array<Array<number>> = [
        [2, 3, 4, 5],
        [2, 3, 4, 5],
        [2, 3, 4, 5],
    ]

    // //底分配置
    // public static difenConfig: Array<number> = [
    //     0.5, 1, 2, 3, 4, 5, 10
    // ]

    public static Ji_Type = {
        danji: 0, //单鸡
        shangxiaji: 1, //上下鸡
        sanji: 2, //三鸡
    }

    public jiType: number = 0
    public static jiTypeNameConfig: Array<string> = [
        "单鸡", "上下鸡", "三鸡"
    ]



    public benbenji: number = 0 //本本鸡

    public jinyinwu: number = 0; //金银乌
    public jianqiwa: number = 0; //见七挖

    public zhuangcheng: number = 0; //庄上必乘
    public ruanyingji: number = 0; //软硬鸡
    public ruanyingdou: number = 0; //软硬豆
    public jiandou: number = 0; //见豆
    public static jiandouConfig: Array<number> = [
        4, 5, 10
    ]

    //大宽张配置
    public static dakuanzhangConfig: Array<number> = [
        4, 5, 10
    ]

    public dakuanzhang: number = 0;
    //大对子配置
    public static daduiziConfig: Array<number> = [
        5, 10, 15, 20, 30
    ]
    public daduizi: number = 0
    //清\杠开配置
    public static qingGangConfig: Array<number> = [
        15, 20, 30, 40, 50
    ]
    public qinggang: number = 0

    public zimo: number = 0
    public static zimoConfig: Array<number> = [
        1, 5, 10
    ]

    public static createConfig() {
        let config: RoomConfig_huanghua_mj = new RoomConfig_huanghua_mj()
        let str:string = LocalStorage.getItem(Local_Key)
        Logger.log("createConfig==", str)
        if(str){
            try {
                let obj:object = JSON.parse(str)
                config.jushu = obj["jushu"]
                config.renshu = obj["renshu"]
                config.jiType = obj["jiType"]
                config.benbenji = obj["benbenji"]
                config.jinyinwu = obj["jinyinwu"]
                config.jianqiwa = obj["jianqiwa"]
                config.zhuangcheng = obj["zhuangcheng"]
                config.ruanyingji = obj["ruanyingji"]
                config.ruanyingdou = obj["ruanyingdou"]
                config.jiandou = obj["jiandou"]
                config.dakuanzhang = obj["dakuanzhang"]
                config.daduizi = obj["daduizi"]
                config.qinggang = obj["qinggang"]
                config.zimo = obj["zimo"]
                config.distance_limit = obj["distance_limit"]
            } catch (error) {
                
            }
        }
        return config
    }

    public static saveConfig(config:RoomConfig_huanghua_mj){
        LocalStorage.setItem(Local_Key, JSON.stringify(config))
    }

}